package com.yunbiao.ybbusstopplate.utils.eventbus

import com.yunbiao.ybbusstopplate.bean.SiteInfoBean
import org.greenrobot.eventbus.EventBus

class EventMsgTool {
    companion object{
        private var eventMsgTool:EventMsgTool?=null
        fun getInstance():EventMsgTool{
            if (eventMsgTool==null){
                eventMsgTool= EventMsgTool()
            }
            return eventMsgTool!!
        }
    }
    constructor()

    fun postMsg(eventMessage: EventMessage){
        EventBus.getDefault().post(eventMessage)
    }

    fun getEventMessage(tag:Int,msg:String,data:Any?):EventMessage{
        return EventMessage(tag,msg,data)
    }

    //-------------------------------------
    fun postSiteList(siteList: ArrayList<String>){
        postMsg(getEventMessage(EventTAG.EVENT_UPDATESITELIST,"list",siteList))
    }

    fun postLineInfo(lineInfoArray: Array<String>){
        postMsg(getEventMessage(EventTAG.EVENT_LINEINFO,"array",lineInfoArray))
    }

    fun postSiteTime(siteTimes: Array<String>){
        postMsg(getEventMessage(EventTAG.EVENT_SITETIME,"array",siteTimes))
    }

    fun postSiteTip(siteInfoBean: SiteInfoBean){
        postMsg(getEventMessage(EventTAG.EVENT_SITETIP,"siteInfo",siteInfoBean))
    }

    fun postGoMianFragment(){
        postMsg(getEventMessage(EventTAG.EVENT_TOMAIN,"toMainFragment",null))
    }

    fun postShowConfig(){
        postMsg(getEventMessage(EventTAG.event_config_show,"show",null))
    }
    fun postDismissConfig(){
        postMsg(getEventMessage(EventTAG.event_config_dismiss,"show",null))
    }

    //配置更新通知
    fun postUpdateConig(){
        postMsg(getEventMessage(EventTAG.event_config_update,"updateConfig",null))
    }

}